// 引入event模块
let events = require('events');
// 创建事件触发对象
let eventEmitter = new events.EventEmitter();

// 事件处理程序
let connectHandler = function connect() {
	console.log('这是connectHandler函数, 连接成功!');
	
	eventEmitter.emit('data-received');
}

let receivedHandler = function received() {
	console.log('这是receivedHandler函数, 接收成功!');
}

// 绑定connect事件处理程序
eventEmitter.on('connection', connectHandler);
// 绑定received事件处理程序
eventEmitter.on('data-received', receivedHandler);



// 触发一下connect事件
eventEmitter.emit('connection');

console.log('所有程序执行完毕!');